package com.itheima.edu.info.manager.factory;

import com.itheima.edu.info.manager.dao.OtherStudentDao;
import com.itheima.edu.info.manager.dao.TeacherDao;

import java.util.Properties;
import java.util.ResourceBundle;

public class TeacherFactory {
    //注意: 当方法的返回值类型是一个接口类型时,方法中需要返回的是该接口的实现类对象
    public static TeacherDao getTeacherDao1() {
        return new TeacherDao();
    }

    public static TeacherDao getTeacherDao() {

        try {
            //1.使用properties读取配置信息
            Properties prop = new Properties();
            prop.load(StudentFactory.class.getClassLoader().getResourceAsStream("prop.properties"));
            //1.反射获取类对象
            Class clazz = Class.forName(prop.getProperty("TeacherName"));
            return (TeacherDao) clazz.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}


